<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
	<link rel="stylesheet" href="/static/wx/css/mui.min.css">
	<link rel="stylesheet" href="/static/wx/css/mui.picker.css">
	<link rel="stylesheet" href="/static/wx/css/mui.poppicker.css">

</head>
<style>
	.address{
	line-height: 40px;
	vertical-align: middle;
}
</style>

<body>
	<header class="mui-bar mui-bar-nav">
		<h1 id="title" class="mui-title">申请入驻</h1>
	</header>
	<div class="mui-content" style="">
		<form class="mui-input-group">

			<div class="mui-input-row">
				<label>机构名称</label>
				<input id='name' type="text" class="mui-input-clear mui-input" placeholder="请输入机构名称">
			</div>

			<div class="mui-input-row">
				<label>联系人</label>
				<input id='truename' type="text" class="mui-input-clear mui-input" placeholder="请输入联系人">
			</div>
			<div class="mui-input-row">
				<label>联系手机</label>
				<input id='phone' type="number" class="mui-input-clear mui-input" placeholder="请输入手机号码">
			</div>
			<div class="mui-input-row">
				<label>验证码</label>
				<input id='code' type="number" style="width:40%;float: left;" class="mui-input-clear mui-input" placeholder="请输入验证码">
				<button type="button" id="getcode" style="float:right;" class="mui-btn mui-btn-primary">获取</button>
			</div>
			<div class="mui-input-row">
				<label>选择地区</label><span id="address" style="width:120px !important;font-size:14px;" class="address"></span>
				<button type="button" onclick="choosecity()" class="mui-btn mui-btn-primary">选择</button>
			</div>
			<div class="mui-content-padded">
				<div class="mui-inline">机构简介</div>

			</div>
			<div class="row mui-input-row" style="height:100px;">
				<textarea id='desc' style="height: 100px;" class="mui-input-clear question" placeholder=""></textarea>
			</div>

		</form>
		<div class="mui-content-padded">
			<button id='sendMail' class="mui-btn mui-btn-block mui-btn-primary">提交</button>
		</div>

		<input type="hidden" id="addresscode" value="" />
		<input type="hidden" id="openid" value="{$openid}" />
	</div>
</body>
<script src="/static/js/jquery.js"></script>
<script src="/static/wx/js/mui.min.js"></script>
<script src="/static/wx/js/mui.picker.js"></script>
<script src="/static/wx/js/mui.poppicker.js"></script>
<script src="/static/js/city.data-3.js"></script>
<script type="text/javascript" charset="utf-8">
	//mui初始化
	mui.init();



	mui.ready(function () {


	});


	mui('.mui-content-padded').on('tap', '#sendMail', function (e) {
		var name = $("#name").val();
		var truename = $("#truename").val();
		var phone = $("#phone").val();
		var address = $("#address").html();
		var addresscode = $("#addresscode").val();
		var code = $("#code").val();
		var desc = $("#desc").val();
		if (name == "") {
			mui.toast("请输入机构名称");
		} else if (truename == "") {
			mui.toast("请输入联系人");
		} else if (phone == "") {
			mui.toast("请输入联系方式");
		} else if (!(/^1[34578]\d{9}$/.test(phone))) {
			mui.toast("手机号有误");
		} else if (address == "") {
			mui.toast("请选择地址");
		} else if (code == "") {
			mui.toast("请输入手机验证码");
		} else {
			var openid = $("#openid").val();
			$.post("/wx/Index/mechanismsq", { name: name, truename: truename, phone: phone, address: address, addresscode: addresscode, desc: desc, code: code, openid: openid }, function (data) {

				if (data.status == 200) {
					mui.alert(data.message, function () {
						WeixinJSBridge.call('closeWindow');
					});
				} else {
					mui.toast(data.message);
				}


			});
		}

	});
	var disabled = true;
	$(function () {
		$("#getcode").click(function () {



			var phone = $("#phone").val();
			if (!(/^1[34578]\d{9}$/.test(phone))) {
				mui.toast("手机号有误");
				disabled = true;
			} else if (disabled) {
				disabled = false;
				$.post("/Wx/Index/checkphone", { phone: phone }, function (data2) {
					if (data2.status == 200) {
						$.post('/Wx/Index/getcode', {
							"phone": phone
						}, function (data) {
							if (data.status == 200) {
								var num = 61;

								var timer = setInterval(function () {
									num--;
									if (num <= 0) {
										clearInterval(timer);
										$("#getcode").html("重新发送");

										disabled = true;

									} else {
										$("#getcode").html(num + "s");

										disabled = false;
									}
								}, 1000)
							} else {
								mui.toast(data.message);
							}
						});

					} else {
						disabled = true;
						mui.toast(data2.message);
					}

				});



			}

		});

	});
	function choosecity() {

		var picker = new mui.PopPicker({
			layer: 3
		});

		picker.setData(cityData3);
		picker.show(function (selectItems) {

			var ss = picker.getSelectedItems();

			$("#address").html(ss[0].text + "-" + ss[1].text + "-" + ss[2].text);

			$("#addresscode").val(ss[2].value);

		})
	}

</script>

</html>